import 'package:FineArt/components/azlist/az_common.dart';
import 'package:FineArt/core/http/base_dio.dart';
import 'package:json_annotation/json_annotation.dart';
import 'package:retrofit/retrofit.dart';
import 'package:dio/dio.dart';
import '../../constants.dart';

part 'class_api.g.dart';

@RestApi(baseUrl: kBaseUrl)
abstract class ClassApi {
  factory ClassApi({Dio dio, String baseUrl}) {
    dio ??= BaseDio.getInstance().getDio();
    return _ClassApi(dio, baseUrl: baseUrl);
  }

  //拉取自己的班级列表,注意，对于老师可能是多个班级，对于学生，班级数组只能有一个。
  @GET("/api/v1/class")
  Future<ClassesResponse> classList();

  //拉取指定班级的学生列表
  @GET("/api/v1/class/{id}/students")
  Future<StudentsResponse> studentList(@Path("id") int classId);
  //获取未分配班级的学生列表
  @GET("/api/v1/classmembers/list/student")//classStatus=1&postId=2&roleId=1003固定值  postId 1 老师 postId 2 学生
  Future<ContactsResponse> unSelectStudent(@Query("classStatus") int classStatus, @Query("postId") int postId,
      @Query("roleId") int roleId);
  //拉取老师的班级列表
  @GET("/api/v1/teacherclasses/{uid}/")
  Future<TeacherClassesResponse> teacherclasses(@Path("uid") String uid);
  //创建基于班级id的教学会话。
  @POST("/api/v1/course/{id}")
  Future<CreateCourseResponse> createCourse(
      @Path("id") int classId, @Body() CourseBody course);

  //获取教学会话列表，注意一个班级同时只能有一个教学会话，这里采用列表只是为了考虑后续扩展。
  @GET("/api/v1/course")
  Future<CourseListResponse> courseList();

  @DELETE("/api/v1/classmembers/student") //移除班级学生
  Future<ClassesMemberResponse> removeClassStudent(@Body() StudentDelRequestBody body);

  @POST("/api/v1/classmembers/addstudent") //添加班级学生
  Future<ClassesMemberResponse> addClassStudent(@Body() StudentDelRequestBody body);
}
@JsonSerializable()
class StudentDelRequestBody {
  List<String> uids;
  int cid;
  StudentDelRequestBody(this.uids,this.cid);

  Map<String, dynamic> toJson() => _$StudentDelRequestBodyToJson(this);
}
////////////////
@JsonSerializable()
class ClassesResponse {
  String requestId;
  String msg;
  int code;
  List<Class> data;

  ClassesResponse({this.code, this.data,this.requestId,this.msg});

  factory ClassesResponse.fromJson(Map<String, dynamic> json) =>
      _$ClassesResponseFromJson(json);
}
@JsonSerializable()
class ClassesMemberResponse {
  String requestId;
  String msg;
  int code;
  int data;

  ClassesMemberResponse({this.code, this.data,this.requestId,this.msg});

  factory ClassesMemberResponse.fromJson(Map<String, dynamic> json) =>
      _$ClassesMemberResponseFromJson(json);
}
@JsonSerializable()
class TeacherClassesResponse {
  String requestId;
  String msg;
  int code;
  List<TeacherClassesEntity> data;

  TeacherClassesResponse({this.code, this.data,this.requestId,this.msg});

  factory TeacherClassesResponse.fromJson(Map<String, dynamic> json) =>
      _$TeacherClassesResponseFromJson(json);
}
@JsonSerializable()
class TeacherClassesEntity {
  // classId: 1,
  //               className: "央清三班",
  //               describe: "三1班",
  //               partnerId: 13,
  //               userId: "14237915722812103",
  //               status: "2",
  //               reserve: "",
  //               createdAt: "2021-04-05T13:15:11+08:00",
  //               updatedAt: "2021-04-13T09:38:42.176+08:00",
  //               createBy: 100002,
  //               updateBy: 100002
  String className;
  String describe;
  String userId;
  String status;
  String reserve;
  String createdAt;
  String updatedAt;
  int partnerId;
  int classId;
  int createBy;
  int updateBy;


  TeacherClassesEntity({this.className,this.describe,this.userId,this.reserve,
    this.createdAt,this.updatedAt,this.partnerId,this.classId,this.createBy,this.updateBy,this.status});

  factory TeacherClassesEntity.fromJson(Map<String, dynamic> json) =>
      _$TeacherClassesEntityFromJson(json);
}
@JsonSerializable()
class Class {
  int classid;
  String classname; //班级名称
  int userid;//班主任id
  Class({this.classid, this.classname,this.userid});

  factory Class.fromJson(Map<String, dynamic> json) => _$ClassFromJson(json);
}

///////////////
////////////////
@JsonSerializable()
class StudentsResponse {
  int code;
  String msg;
  String requestId;
  List<Student> data;

  StudentsResponse({this.code, this.data,this.requestId, this.msg});

  factory StudentsResponse.fromJson(Map<String, dynamic> json) =>
      _$StudentsResponseFromJson(json);
}
@JsonSerializable()
class ContactsResponse {
  int code;
  String msg;
  String requestId;
  ContactsData data;

  ContactsResponse({this.code, this.data,this.requestId, this.msg});

  factory ContactsResponse.fromJson(Map<String, dynamic> json) =>
      _$ContactsResponseFromJson(json);
}
@JsonSerializable()
class ContactsData {
  int count;
  int pageIndex;
  int pageSize;
  List<ContactInfo> list;

  ContactsData({this.count, this.pageIndex,this.pageSize, this.list});

  factory ContactsData.fromJson(Map<String, dynamic> json) =>
      _$ContactsDataFromJson(json);
}
@JsonSerializable()
class ContactInfo extends ISuspensionBean{
  int uid; //学生id
  String portrait;//头像
  int id;
  String userId;
  int partnerId;
  String username;
  String  nickName;
  String name;
  String phone;
  String email;
  String card;
  int roleId;
  String postId;
  String ssoId;
  String avatar;
  String sex;
  String birthday;
  String viplevel;
  String status;
  String classStatus;
  String isLock;
  String lastLoginAt;
  int passErrTimes;
  String remark;
  String createdAt;
  String updatedAt;
  int createBy;
  int updateBy;
  String className;
  int activeStatus;
  bool isCheck;
  String namePinyin;
  String tagIndex;
  // id: 101446,
  // userId: "39154359426128955",
  // partnerId: 13,
  // username: "18135219003",
  // nickName: "李繁",
  // name: "李繁",
  // phone: "18135219003",
  // email: "",
  // card: "",
  // roleId: 1003,
  // postId: "2",
  // ssoId: "",
  // avatar: "",
  // sex: "0",
  // birthday: "2021-09-28T10:43:36.855+08:00",
  // viplevel: "0",
  // status: "2",
  // classStatus: "2",
  // isLock: "1",
  // lastLoginAt: "2021-09-28T10:43:36.855+08:00",
  // passErrTimes: 0,
  // remark: "",
  // createdAt: "2021-09-28T10:43:36.927+08:00",
  // updatedAt: "2021-09-28T10:43:36.927+08:00",
  // createBy: 100004,
  // updateBy: 0,
  // className: "三班",
  // activeStatus: 1

  
  
  
  ContactInfo({this.name, this.uid,this.portrait,this.nickName,this.className,this.id,this.postId});

  factory ContactInfo.fromJson(Map<String, dynamic> json) =>
      _$ContactInfoFromJson(json);

  @override
  String getSuspensionTag() {
    return  tagIndex;
  }
}
@JsonSerializable()
class Student {
  String name; //学生名称
  int uid; //学生id
  String portrait;//头像
  Student({this.name, this.uid,this.portrait});

  factory Student.fromJson(Map<String, dynamic> json) =>
      _$StudentFromJson(json);
}

///////////////
////////////////
@JsonSerializable()
class CreateCourseResponse {
  int code;
  String msg;
  String requestId;
  CreateResult data;

  CreateCourseResponse({this.code, this.data});

  factory CreateCourseResponse.fromJson(Map<String, dynamic> json) =>
      _$CreateCourseResponseFromJson(json);
}

@JsonSerializable()
class CreateResult {
  int courseid; //  教学会话id       // 注意订阅这个会话id的mqtt 主题（有别于个人uid的订阅主题）

  CreateResult({this.courseid});

  factory CreateResult.fromJson(Map<String, dynamic> json) =>
      _$CreateResultFromJson(json);
}

@JsonSerializable()
class CourseBody {
  List<String> members; //  摇投送和同步的成员uid数组，这里一般是所选择的学生列表uid
  int id; //  课件id,就是资源id,比如图书的id,照片id,环拍id或者教学课件id.
  int layout; //  横版还是竖版vertical ,横版horizontal
  int type;
  int subitem;

  CourseBody({this.members, this.id, this.layout,this.type,this.subitem});

  Map<String, dynamic> toJson() => _$CourseBodyToJson(this);
}

///////////////
////////////////
@JsonSerializable()
class CourseListResponse {
  int code;
  String msg;
  String requestId;
  List<Course> data;

  CourseListResponse({this.code, this.data,this.msg,this.requestId});

  factory CourseListResponse.fromJson(Map<String, dynamic> json) =>
      _$CourseListResponseFromJson(json);
}

@JsonSerializable()
class Course {
  int Id; //教学会话id
  int AssetId;
  String TeacherId;
  int Layout;
  int Step;
  int AssetType;
  Course({this.Id, this.AssetId,this.TeacherId,this.Layout,this.Step,this.AssetType});

  factory Course.fromJson(Map<String, dynamic> json) => _$CourseFromJson(json);
}


@JsonSerializable()
class MatrixOperation {
  double scale;
  double mins;
  double maxs;
  double left;
  double top;
  double width;

  MatrixOperation({this.scale,this.mins,this.maxs,this.left,this.top,this.width});

  Map<String, dynamic> toJson() => _$MatrixOperationToJson(this);
}

///////////////
